package com.xijia;


/**
 * 静态方法区
 * @author wangsong
 * @mail 1720696548@qq.com
 * @date 2020/9/5 0005 10:14
 * @version 1.0.0
 */
public class Singleton05 {


    private static Singleton05 singleton05 = null;

    private Singleton05() {
    }

    /**
     * 只会初始化一次（或常用的 init方法）
     */
    static {
        System.out.println("当前class被加载");
        singleton05 = new Singleton05();
    }

    public static synchronized Singleton05 getInstance() {
        return Singleton05.singleton05;
    }


    public static void main(String[] args) {
        System.out.println(Singleton05.getInstance() == Singleton05.getInstance());
    }
}
